From: Eric Huss Date: Thu, 5 Apr 2018 12:39:50 +0000 (-0700) Subject: Pass edition to rustdoc. X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~94^2~2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=bbb2b92ef8750aacf1a034613715ae572ffd674c;p=cargo.git Pass edition to rustdoc. Fixes #5279. --- diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 5f7569482..f467cc6ee 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -776,6 +776,13 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); } + let manifest = unit.pkg.manifest(); + + if manifest.features().is_enabled(Feature::edition()) { + rustdoc.arg("-Zunstable-options"); + rustdoc.arg(format!("--edition={}", &manifest.edition())); + } + if let Some(ref args) = unit.profile.rustdoc_args { rustdoc.args(args); } diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 7b6ea41e3..e3ca13e92 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -3,7 +3,7 @@ use std::str; use std::fs::{self, File}; use std::io::Read; -use cargotest::rustc_host; +use cargotest::{rustc_host, ChannelChanger}; use cargotest::support::{execs, project, path2url}; use cargotest::support::registry::Package; use hamcrest::{assert_that, existing_dir, existing_file, is_not}; @@ -1464,3 +1464,33 @@ fn doc_workspace_open_help_message() { .with_stderr_contains(" bar"), ); } + +#[test] +fn doc_edition() { + if !cargotest::is_nightly() { + // Stable rustdoc won't have the edition option. Remove this once it + // is stabilized. + return; + } + let p = project("foo") + .file( + "Cargo.toml", + r#" + cargo-features = ["edition"] + [package] + name = "foo" + version = "0.0.1" + authors = [] + rust = "2018" + "#, + ) + .file("src/lib.rs", "") + .build(); + + assert_that( + p.cargo("doc").arg("-v").masquerade_as_nightly_cargo(), + execs() + .with_status(0) + .with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]"), + ); +}